/* @(#)GSOperatorScanQueryAction.java    
 *
 * Project: BUS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Jenny Li     2006-2-10    建立
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSOperatorProcessor;
import com.hitrust.gs.business.GSOrgProcessor;
import com.hitrust.gs.form.GSOperatorScanQueryForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.page.ResultProcess;

/**
 * 查询操作员信息
 *
 */
public class GSOperatorScanQueryAction extends GSBaseAction {

	public String execute(GSBaseForm aForm) throws Exception {
		GSOperatorScanQueryForm tForm = (GSOperatorScanQueryForm)aForm;
        //取得页面查询参数
		GSOperatorBean tGSOperatorBean = new GSOperatorBean();
		tGSOperatorBean.setGs_oper_id(tForm.getOperId());
		tGSOperatorBean.setGs_oper_name(tForm.getOperName());
		tGSOperatorBean.setGs_oper_org_id(tForm.getOperOrgId());
		tGSOperatorBean.setGs_key_word(tForm.getKeyWord());
        
        GSOperatorBean tGSCurOperator = (GSOperatorBean)tForm.getRequest().getSession().getAttribute(GSBaseConstants.LOGIN);
        //查询符合条件的操作员
        ResultProcess tProc = null;
        try{
    		GSOperatorProcessor tGSOperatorProc = new GSOperatorProcessor();
    		tProc = tGSOperatorProc.getOperatorsByOpt(tGSOperatorBean,tGSCurOperator);
        }catch(GSException e){
            aForm.getRequest().setAttribute("action","A200301.do");
            throw e;
        }
		tForm.getRequest().setAttribute("Operator",tProc);
        //暂时用此方法传递分页参数
//        tForm.getRequest().setAttribute("choice",tForm.getRequest().getParameter("choice"));
		

        GSOrgProcessor tGSOrgProc = new GSOrgProcessor();
        //取得可查询操作员及组织之间的关系集
        GSOperatorBean tGSOperatorBean1 = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        HashMap tMap = GSOperatorProcessor.getViewableOrgAndOperator(tGSOperatorBean1);
        
        //取得操作员所属企业及其所有下级企业
		ArrayList tList = tGSOrgProc.getOperOrgAndSubOrg(tGSCurOperator.getGs_oper_org_id());
		aForm.getRequest().setAttribute("Organization",tList);
        
        tMap.remove("organization");
        
        GSOperatorProcessor tGSOperProc = new GSOperatorProcessor();
        ArrayList tList2 = tGSOperProc.getViewableOperByLoginOper(tGSOperatorBean1.getGs_oper_id(),tGSOperatorBean1.getGs_oper_org_id());
        aForm.getRequest().setAttribute("OperatorsList",tList2);
        
        tMap.remove("OperatorsList");
        
        aForm.getRequest().setAttribute("OrgAndOper",tMap);
        
		return GSBaseConstants.FORWARD_SUCCESS;
	}

}
